import { TabBar, UserPagesConfig } from '@uni-helper/vite-plugin-uni-pages';

import pagesJson from '@/pages.json';

import type { TabBarType } from '../';

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const tabBar: TabBar = (pagesJson as UserPagesConfig).tabBar || { list: [] };

/** tabbarList 从 pages.config.ts 获取 */
export const tabBarList: TabBarType[] = tabBar.list.map((item) => {
  const tabbar = {
    /** 编号 */
    id: item.id,
    /** 图标类型 */
    iconType: item.iconType || 'local',
    /** 图标 */
    icon: item.icon,
    ...item,
  };
  return tabbar;
});
